import 'package:flutter/material.dart';
import 'package:flutterroom/pages/home/home_page.dart';
import 'package:flutterroom/pages/home/tab_info/info_tab_page.dart';
import 'package:flutterroom/pages/home/tab_search/search_index.dart';
import 'package:flutterroom/pages/my/my_tab.dart';
import 'package:flutterroom/widgets/page_content.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

List<Widget> tableViewList = [
  HomdeIndexPage(),
  SearchIndexPage(),
  InfoTabpage(),
  MyTabPage(),
];

List<BottomNavigationBarItem> barItemList=[
BottomNavigationBarItem(title:Text("首页"),icon: Icon(Icons.home)), 
BottomNavigationBarItem(title:Text("搜索"),icon: Icon(Icons.search)), 
BottomNavigationBarItem(title:Text("咨询"),icon: Icon(Icons.info)), 
BottomNavigationBarItem(title:Text("我的"),icon: Icon(Icons.account_circle)), 
];

class HomePage extends StatefulWidget {
  HomePage({Key key}) : super(key: key);

  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  int _selectedIndex =0;
  void _onItemtapped(int index){
    setState(() {
      _selectedIndex=index;
    });
  }
  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(context, width: 750, height: 1334);
    return Scaffold(
      body: tableViewList[_selectedIndex],
      bottomNavigationBar: BottomNavigationBar(
        type: BottomNavigationBarType.fixed,
        items: barItemList,
        currentIndex: _selectedIndex,
        onTap: _onItemtapped,
        selectedItemColor: Colors.green,
        ),
    );
    
  }
}
